home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dec92.zip / 1012018A < prev    next >
Text File  |  1992-10-06  |  381b  |  17 lines

  1. /* strspn function */
  2. #include <string.h>
  3.  
  4. size_t (strspn)(const char *s1, const char *s2)
  5.     {    /* find index of first s1[i] that matches no s2[] */
  6.     const char *sc1, *sc2;
  7.  
  8.     for (sc1 = s1; *sc1 != '\0'; ++sc1)
  9.         for (sc2 = s2; ; ++sc2)
  10.             if (*sc2 == '\0')
  11.                 return (sc1 - s1);
  12.             else if (*sc1 == *sc2)
  13.                 break;
  14.     return (sc1 - s1);    /* null doesn't match */
  15.     }
  16.  
  17.